package cn.good.yan.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

/**
 * 库存实体
 *
 * @author shengren.yan
 * @create 2024-02-22
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@TableName(value = "t_storage")
@ToString
public class Storage {

    @TableId(value = "id", type = IdType.INPUT)
    private Long id;

    /**
     * 产品id
     */
    @TableField(value = "product_id")
    private Long productId;

    /**
     * 总库存
     */
    @TableField(value = "total")
    private Integer total;

    /**
     * 已用库存
     */
    @TableField(value = "used")
    private Integer used;

    /**
     * 剩余库存
     */
    @TableField(value = "residue")
    private Integer residue;


}

//    CREATE DATABASE seata_storage;
//
//    CREATE TABLE t_storage (
//    `id` BIGINT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
//    `product_id` BIGINT(11) DEFAULT NULL COMMENT '产品id',
//    `total` INT(11) DEFAULT NULL COMMENT '总库存',
//    `used` INT(11) DEFAULT NULL COMMENT '已用库存',
//    `residue` INT(11) DEFAULT NULL COMMENT '剩余库存'
//    ) ENGINE=INNODB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
//
//    INSERT INTO seata_storage.t_storage(`id`, `product_id`, `total`, `used`, `residue`)
//    VALUES ('1', '1', '100', '0', '100');
//    SELECT * FROM t_storage;
